package com.young.freedom.spring.aop.aspect;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.DeclareParents;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.young.freedom.aop.DefaultUsageTracked;
import com.young.freedom.aop.UsageTracked;


@Component
@Aspect
public class IntroductionAspect {

	static final Logger logger = LoggerFactory.getLogger(NotVeryUsefulAspect.class);
	
	@Pointcut("execution(* com.young.project.freedom.aop.service.*.*(..))")
	public void anyOldTransfer() {}
	
	@DeclareParents(value="com.young.project.freedom.aop.service.*+",
			defaultImpl=DefaultUsageTracked.class)
	public static UsageTracked mixin;
	
	@Before("anyOldTransfer() && this(usageTracked)")
	public void recordUsage(UsageTracked usageTracked){
		usageTracked.track();
	}
}
